﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Asion.Dapper
{
    //此中很多都模仿了 System.ComponentModel.DataAnnotation,如果后续不想自己添加属性也可以直接使用System.ComponentModel.DataAnnotation中的替换
    //https://learn.microsoft.com/zh-cn/dotnet/api/system.componentmodel.dataannotations.editableattribute?view=net-8.0


    /// <summary>
    /// 库名特性标记
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public class TenantAttribute : Attribute
    {
        /// <summary>
        /// Optional Table attribute.
        /// </summary>
        /// <param name="name"></param>
        public TenantAttribute(string name)
        {
            Name = name;
        }
        /// <summary>
        /// Name of the table
        /// </summary>
        public string Name { get; private set; }

    }




    /// <summary>
    /// 表名特性标记
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public class TableAttribute : Attribute
    {
        /// <summary>
        /// Optional Table attribute.
        /// </summary>
        /// <param name="tableName"></param>
        public TableAttribute(string tableName)
        {
            Name = tableName;
        }
        /// <summary>
        /// Name of the table
        /// </summary>
        public string Name { get; private set; }
    }


    /// <summary>
    ///  列名特性标记
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class ColumnAttribute : Attribute
    {
        /// <summary>
        /// Optional Column attribute.
        /// </summary>
        /// <param name="columnName"></param>
        public ColumnAttribute(string columnName)
        {
            Name = columnName;
        }
        /// <summary>
        /// Name of the column
        /// </summary>
        public string Name { get; private set; }
    }

    /// <summary>
    ///  主键标记
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class KeyAttribute : Attribute
    {
    }


    /// <summary>
    ///  Code
    ///  <para>如果标识了code的属性，在insert语句中会默认生成一个唯一code，但是如果标识的字符串不为空则不生成</para>
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class CodeAttribute : Attribute
    {
    }

    /// <summary>
    /// NotMapped attribute.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class NotMappedAttribute : SimpleMethodBaseAttribute
    {
    }

    /// <summary>
    /// <para>指定数据字段值是必需的标记<para>
    /// <para>优先级最大 例如：当有标记[key]默认子插入的时候会排除，但是如果加上了[Required]还是会将Id列插入<para>
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class RequiredAttribute : SimpleMethodBaseAttribute
    {
    }

    /// <summary>
    ///忽略查询标记
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class IgnoreSelectAttribute : SimpleMethodBaseAttribute
    {
    }

    /// <summary>
    /// 忽略插入特性标记
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class IgnoreInsertAttribute : SimpleMethodBaseAttribute
    {
    }

    /// <summary>
    ///  忽略更新标记
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class IgnoreUpdateAttribute : SimpleMethodBaseAttribute
    {
    }


    /// <summary>
    /// 查询特性标记
    /// </summary>
    [AttributeUsage(AttributeTargets.Method)]
    public class QueryAttribute : Attribute
    {
        /// <summary>
        /// Optional Table attribute.
        /// </summary>
        /// <param name="value"></param>
        public QueryAttribute(string value)
        {
            Value = value;
        }


        /// <summary>
        /// SQL
        /// </summary>
        public string Value { get; set; }

    }

    [AttributeUsage(AttributeTargets.Method)]
    public class SimpleMethodBaseAttribute : Attribute
    {
        
    }




}
